package com.woniu.user.mapper;

import com.woniu.common.entity.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ApplyMapper {

    //犬只审核---申请界面查询
    @Select("select * from apply_for_table ")
    List<ApplyForTable> selectApplies();

    //犬只审核---详情申请界面查询
    @Select("select * from apply_for_table where icd=#{icd}")
    ApplyForTable selectDate(String icd);

    //犬只审核---审核通过
    @Update("update apply_for_table " +
            "set person_info_audit=#{a},pet_infoaudit=#{b},reviewer=#{reviewer}" +
            " where icd=#{icd}")
    void selectApply(@Param("icd") String icd,
                     @Param("a") int a,
                     @Param("b")int b,
                     @Param("reviewer")String reviewer);

    //犬只审核---个人wei通过
    @Update("update apply_for_table " +
            "set person_info_audit=#{i},person_info_failure_reason=#{reason},reviewer=#{reviewer}" +
            " where icd=#{icd}")
    void selectApply2(@Param("icd") String icd,
                      @Param("i") int i,
                      @Param("reason")String reason,
                      @Param("reviewer")String reviewer);

    //犬只审核---犬只wei通过
    @Update("update apply_for_table " +
            "set person_info_audit=#{i},pet_infoaudit=#{j},reviewer=#{reviewer}," +
            "pet_info_failure_reason=#{reason}" +
            " where icd=#{icd}")
    void selectApply3(@Param("icd") String icd,
                      @Param("i") int i,
                      @Param("j") int j,
                      @Param("reason")String reason,
                      @Param("reviewer")String reviewer);
    //审核通过，登记狗信息入库
    @Insert("insert into dog values(null,#{dname},#{sex},'2'," +
            "#{type},#{weight},#{height},#{longth}," +
            "#{dog_positive_image},#{dog_side_image}," +
            "#{regist_date},null,#{num_dog},null,null,null,#{u_id})" )
    void insertDog(Dog dog);
    //犬牌登记
    @Update("update dog " +
            "set dogetc=#{etcnum},dogetc_image=#{url}" +
            " where dname=#{dname} and u_id=#{uid}")
    void updateDognum(@Param("etcnum")String etcnum,
                      @Param("url")String url,
                      @Param("dname") String dname,
                      @Param("uid") int uid);

    //犬只通过审核查询
    @Select("select * from dog ")
    List<Dog> selectDog();

    //通知消息
    @Insert("insert into message values(null,#{title},#{content},#{type},#{u_id},#{status},#{message_time})")
    void insertMessage(Message message);

    //个人消息查询
    @Select("select * from message where u_id=#{uid} ")
    List<Message> selectMessage(int uid);

    //通过account查询用户id
    @Select("select * from user where account=#{account} ")
    User selectUser(String account);

    //修改消息status
    @Update("update message " +
            "set status=#{status}" +
            " where id=#{id}")
    void updateStatus(@Param("status")int status,
                      @Param("id") int id);

    //投诉消息查询
    @Select("select * from complain ")
    List<Complain> selectComplainMessage();
    //投诉消息查询
    @Update("update complain set status=#{status} where id=#{id} ")
    void updaeComplainMessage(@Param("id")int id,@Param("status")int status);

}
